package astar
{
	public class AstarGrid
	{
		private var nodeList:Array;//节点数组
		private var row:int;//行数
		private var col:int;//列数

		public function AstarGrid(r:int, c:int)
		{
			row =r;
			col = c;
			
			nodeList = new Array();
			
			for (var i:int=0; i < row; i++)
			{
				nodeList[i]=new Array();
				for (var j:int=0; j < col; j++)
				{
					nodeList[i][j]=new AstarNode(i, j);
				}
			}
		}
		
		public function getNode(x:int, y:int):AstarNode
		{
			return nodeList[x][y] as AstarNode;
		}
		
		public function setWalkable(x:int, y:int, value:int):void
		{
			if(nodeList[x][y])
				nodeList[x][y].walkable=value;
		}

		public function get numRows():int
		{
			return row;
		}
		
		public function get numCols():int
		{
			return col;
		}
		
	}
}